<include file="Public:header" />
<div class="headbar">
	<div class="position"><span>商品</span><span>></span><span>规格管理</span><span>></span><span>规格列表</span></div>
	<div class="operating">
		<a href="javascript:;"><button class="operating_btn" type="button" onclick="addNewSpec();"><span class="addition">添加规格</span></button></a>
		<a href="javascript:void(0)" onclick="selectAll('id[]')"><button class="operating_btn" type="button"><span class="sel_all">全选</span></button></a>
		<a href="javascript:void(0)" onclick="delModel();"><button class="operating_btn" type="button"><span class="delete">批量删除</span></button></a>
		<a href="{:U('Goods/spec_recycle_list')}"><button class="operating_btn" type="button"><span class="recycle">回收站</span></button></a>
	</div>
</div>
<div class="content">
	<form action="{:U('Goods/spec_del')}" method='post' name='specForm'>
		<table class="list_table">
			<colgroup>
				<col width="40px" />
				<col width="150px" />
				<col width="80px" />
				<col width="220px" />
				<col width="100px" />
			</colgroup>

			<thead>
				<tr>
					<th>选择</th>
					<th>规格名称</th>
					<th>显示方式</th>
					<th>规格数据</th>
					<th>操作</th>
				</tr>
			</thead>

			<tbody>
				<foreach name='spec' item='item' key='key'>
				<tr>
					<td><input type="checkbox" name="id[]" value="{$item.id}" /></td>
					<td>{$item.name}<if condition="$item.note neq null">【"$item.note"】</if></td>
					<td><if condition="$item.type eq 1">文字<else/>图片</if></td>
					<td>
                                                <foreach name="item.spec" item='i'>
							<if condition="$item.type eq 1">
							【{$i}】
							<else/>
							<img class="spec_photo" src="__ROOT__/{$i}" />
                                                        </if>
                                                </foreach>
					</td>
					<td>
						<a href="javascript:addNewSpec({$item['id']});"><img class="operator" src="__PUBLIC__/Partner/images/admin/icon_edit.gif" alt="修改" /></a>
						<a href='javascript:void(0)' onclick="delModel({link:'{:U('Goods/spec_del',array('id' => $item[id]))}'});"><img class="operator" src="__PUBLIC__/Partner/images/admin/icon_del.gif" alt="删除" title="删除" /></a>
					</td>
				</tr>
                                </foreach>
			</tbody>
		</table>
	</form>
</div>
{$page}

<script type='text/javascript'>
    //添加新规格
    function addNewSpec(spec_id)
    {
        var url = "{:U('Goods/spec_edit',array('id'=> '@spec_id@'))}";
        url = url.replace('%40spec_id%40',spec_id?spec_id:0);
        
        art.dialog.open(url,{
            id:'addSpecWin',
            title:'规格设置',
            okVal:'确定',
            ok:function(iframeWin, topWin){
                var formObject = iframeWin.document.forms['specForm'];
                $.post(formObject.action,$(formObject).serialize(),function(json){
                    if(json.flag == 'success')
                    {
                        window.location.reload();
                        return true;
                    }
                    else
                    {
                        alert(json.message);
                        return false;
                    }
                },'json');
            }
        });
    }
</script>
<include file="Public:footer" />